﻿namespace Blaze.Editor
{
    using System;
    using System.Reflection;
    using UnityEditor;

    /// <summary>
    /// 提供<see cref="UnityEditor.LocalizationDatabase"/>的方法调用。
    /// </summary>
    internal static class LocalizationDatabase
    {
        public static string GetLocalizedString(string original)
        {
            return (string) mGetLocalizedStringMethod.Invoke(null, new object[] {original});
        }

        private static readonly Type mLocalizationDatabaseType = Assembly.GetAssembly(typeof(Editor)).GetType("UnityEditor.LocalizationDatabase");
        private static readonly MethodInfo mGetLocalizedStringMethod = mLocalizationDatabaseType.GetMethod("GetLocalizedString", BindingFlags.Public | BindingFlags.Static);
    }
}